0#include <iostream>
#include <cstdio>

using namespace std;
class HasPtr{
public:
    HasPtr(const string &s = string()):ps(new string(s)),i(0),use(new size(1)){ }
    HasPtr(const HasPtr &p):ps(p.ps),i(p.i),...{}
    HasPtr& operator=(const HasPtr&);
    ~HasPtr();
private:
    string *ps;
    int i;
    size_t *use; //to record how many objects shared the member
};
//the key
HasPtrl::~HasPtr(){
    if(--*use == 0){
        delete ps;
        delete ps;
    }
}
HasPtr& HasPtr::operator=(const HasPtr& rhs){
    ++*(rhs.use);
    if(--*use == 0){
        delete ps;
        delete use;
    }
    ps = rhs.ps;
    i = rhs.i;
    use = rhs.use;
    return *this;
}
class Message{
    friend class Folder;
public:
    explicit Message(const string &str = ""):contents(str){}
    Message(const Message&);
    Message& operator=(const Message&);
    ~Message();

    void save(Folder&);
    void remove(Folder&);
private:
    string contents;
    set<Folder*> folders;
    void add_to_Folders(const Message&);
    void remove_from_Folders();
};

void Message::save(Folder& f){
    folders.insert(&f);
    f.addMsg(this);
}

void Message::remove(Folder &f){
    folder.erase(&f);
    f.remMsg(this);
}

//copy construct function
void Message::add_to_Folders(const Message &m){
    for(auto it : m.folders)
        f->addMsg(this);
}

Message::Message(const Message &m){

}
int main(){

    return 0;

}


